var timer = 0,
	index = 0;

//音乐主题切换
function theme() {
	index++;

	$(".music_time span").text(60 - index + "s"); //倒计时
	if(index >= 60) {
		clearInterval(timer);
		index = 0;
	}
	
	switch(index) {
		case 10:
			theme_ani(".old_music", ".popular_music");

			break;
		case 20:
			theme_ani(".popular_music", ".rock_music");

			break;
		case 30:
			theme_ani(".rock_music", ".movie_music");

			break;
		case 40:
			theme_ani(".movie_music", ".classic_music");

			break;
		case 50:
			theme_ani(".classic_music", ".car_music");
			break;
	}
}

function theme_ani(prev, next) {
	$(prev).animate({
		"left": "100%"
	}, 200);
	$(next).animate({
		"left": "0"
	}, 200);

}
timer = setInterval(theme, 1000);

function add_img(tardiv) {
	var divs = $(tardiv).find("div");
	
	for(var i = 0; i < divs.length; i++) {
		var imgsrc = divs.eq(i).find("img").data("src");
		divs.eq(i).find("img").attr("src", imgsrc);
	}
}

//点击马上开始后，开始加载图片
add_img(".popular_music");
add_img(".rock_music");
add_img(".movie_music");
add_img(".classic_music");
add_img(".car_music");
